﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="dataType", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(DataType))]
    public class DataTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDataType clazz;
        
        public DataTypeSerializer(IDataType clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.DATA!=null) {
                Writer.WriteStartElement("DATA");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DATA))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="DATA") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>dataType>DATA");
                }
                clazz.DATA = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("DATA")).Value;
            }
        }
    }
}
